import { TextLoader } from "langchain/document_loaders/fs/text";
import {Chroma} from 'langchain/vectorstores/chroma'
import {myEmbeddings_test} from '../embeddings/index.js'

// Create docs with a loader
const loader = new TextLoader("C:\\Users\\aqua\\Desktop\\fasis.txt");
const docs = await loader.load();

// Create vector store and index the docs
const vectorStore = await Chroma.fromDocuments(docs, myEmbeddings_test, {
    collectionName: "a-test-collection",
});

// Search for the most similar document
const response = await vectorStore.similaritySearchWithScore("hello", 1);

console.log(response);
/*
[
  Document {
    pageContent: 'Foo\nBar\nBaz\n\n',
    metadata: { source: 'src/document_loaders/example_data/example.txt' }
  }
]
*/
